import { createSlice, PayloadAction } from '@reduxjs/toolkit'

export interface userType {
  user_info: IUserInfo
  is_menu_collapsed: boolean
  is_full_screen: boolean
}

export interface IUserInfo {
  id?: string
  phoneNumber?: string
  userId?: number
  userName?: string
  workId?: number
  applicationId?: string
  orgId?: number
  orgName?: string
}

const initialState: userType = {
  user_info: {},
  is_menu_collapsed: false,
  is_full_screen: false,
}
export const userSlice = createSlice({
  name: 'user',
  initialState,
  reducers: {
    changeUserInfoAction(state, action: PayloadAction<IUserInfo>) {
      state.user_info = action.payload
    },
    changeMenuCollapsed(state, action: PayloadAction<boolean>) {
      state.is_menu_collapsed = action.payload
    },
    changeFullScreen(state, action: PayloadAction<boolean>) {
      state.is_full_screen = action.payload
    },
  },
})
export const { changeUserInfoAction, changeMenuCollapsed, changeFullScreen } = userSlice.actions
export default userSlice.reducer
